package com.jackrain.nea.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.jackrain.nea.util.WebUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;


/**
 * Created by USER-PC on 2016/7/22 0022.
 */
@RestController
public class ValidateController {
    private String key = "raincloud";

    @RequestMapping(value="/p/c/getCaptcha")
    public JSONObject getCaptcha(HttpServletRequest request, HttpServletResponse response){
        String data = String.valueOf((new Date()).getTime());
        String hash = WebUtils.encryptBasedDes(data, key.getBytes());
        JSONObject jo = new JSONObject();
        jo.put("captcha",hash);
        return jo;
    }

}
